home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Toolbox / Visual Basic Toolbox (P.I.E.)(1996).ISO / forms / frmwiz / dataform.frm < prev    next >
Text File  |  1995-01-28  |  30KB  |  1,110 lines

  1. VERSION 2.00
  2. Begin Form DataForm
  3. HelpContextID = 73
  4. BackColor       =   &H00C0C0C0&
  5. Caption         =   "Form Wizard"
  6. ClientHeight    =   4950
  7. ClientLeft      =   765
  8. ClientTop       =   1485
  9. ClientWidth     =   8010
  10. Height          =   5355
  11. Icon            =   DATAFORM.FRX:0000
  12. Left            =   705
  13. LinkTopic       =   "Form1"
  14. ScaleHeight     =   4950
  15. ScaleWidth      =   8010
  16. Top             =   1140
  17. Width           =   8130
  18. Begin VideoSoftIndexTab VSIndexTab1
  19. Align           =   1  'Align Top
  20. BackSheets      =   0  'None
  21. BackTabColor    =   &H00FF0000&
  22. Caption         =   "Data Control|Fields|Form"
  23. CaptionStyle    =   1  'Raised
  24. ConvInfo        =   DATAFORM.FRX:0302
  25. FontBold        =   0   'False
  26. FontItalic      =   0   'False
  27. FontName        =   "MS Sans Serif"
  28. FontSize        =   13.5
  29. FontStrikethru  =   0   'False
  30. FontUnderline   =   0   'False
  31. FrontTabColor   =   &H00C0C0C0&
  32. Height          =   4995
  33. Left            =   0
  34. Position        =   0  'Top
  35. Style           =   5  'Chamfered 3D
  36. TabIndex        =   16
  37. Top             =   0
  38. Width           =   8010
  39. Begin VideoSoftElastic VSElastic2
  40. HelpContextID = 25
  41. BevelChildren   =   4  'Only Graphical
  42. ConvInfo        =   DATAFORM.FRX:030D
  43. Height          =   4455
  44. IntBkg          =   &H00C0C0C0&
  45. Left            =   9870
  46. TabIndex        =   20
  47. Top             =   495
  48. Width           =   7920
  49. Begin VideoSoftElastic VSElastic3
  50. BevelOuter      =   0  'None
  51. ConvInfo        =   DATAFORM.FRX:0318
  52. Height          =   3105
  53. IntBkg          =   &H00C0C0C0&
  54. Left            =   2760
  55. TabIndex        =   26
  56. Top             =   300
  57. Width           =   1110
  58. Begin SSCommand BtnAdd
  59. HelpContextID = 29
  60. AutoSize        =   2  'Adjust Button Size To Picture
  61. Caption         =   "&Add"
  62. Font3D          =   2  'Raised w/heavy shading
  63. Height          =   555
  64. Left            =   60
  65. Picture         =   DATAFORM.FRX:0323
  66. TabIndex        =   30
  67. Tag             =   "Add selected field(s) to the form"
  68. Top             =   240
  69. Width           =   915
  70. End
  71. Begin SSCommand BtnRemove
  72. HelpContextID = 28
  73. AutoSize        =   2  'Adjust Button Size To Picture
  74. Caption         =   "&Remove"
  75. Font3D          =   2  'Raised w/heavy shading
  76. Height          =   555
  77. Left            =   60
  78. Picture         =   DATAFORM.FRX:0625
  79. TabIndex        =   29
  80. Tag             =   "Remove selected field(s) from the form"
  81. Top             =   840
  82. Width           =   915
  83. End
  84. Begin SSCommand BtnCancel
  85. AutoSize        =   2  'Adjust Button Size To Picture
  86. Caption         =   "&Cancel"
  87. Font3D          =   2  'Raised w/heavy shading
  88. Height          =   615
  89. Index           =   1
  90. Left            =   60
  91. Picture         =   DATAFORM.FRX:0927
  92. TabIndex        =   28
  93. Tag             =   "Cancel building the form"
  94. Top             =   1500
  95. Width           =   915
  96. End
  97. Begin SSCommand BtnHelp
  98. Caption         =   "&Help"
  99. Font3D          =   2  'Raised w/heavy shading
  100. Height          =   615
  101. Index           =   1
  102. Left            =   60
  103. Picture         =   DATAFORM.FRX:0C29
  104. TabIndex        =   27
  105. Top             =   2220
  106. Width           =   915
  107. End
  108. End
  109. Begin VideoSoftElastic cMsg
  110. Align           =   2  'Bottom
  111. BevelChildren   =   3  'No Graphical or Elastics
  112. BevelInner      =   0  'None
  113. BevelOuter      =   5  'Fillet
  114. BevelOuterWidth =   4
  115. ConvInfo        =   DATAFORM.FRX:0F2B
  116. ForeColor       =   &H00FF0000&
  117. Height          =   375
  118. Index           =   1
  119. IntBkg          =   &H00C0C0C0&
  120. Left            =   0
  121. TabIndex        =   25
  122. Top             =   4080
  123. Width           =   7920
  124. End
  125. Begin SSFrame Frame3D1
  126. Alignment       =   2  'Center
  127. Caption         =   "Select Fields For Form"
  128. ForeColor       =   &H00FF0000&
  129. Height          =   3795
  130. Left            =   90
  131. TabIndex        =   23
  132. Top             =   90
  133. Width           =   2595
  134. Begin ListBox LstFields
  135. HelpContextID = 27
  136. BackColor       =   &H00C0C0C0&
  137. Height          =   3345
  138. Left            =   120
  139. MultiSelect     =   2  'Extended
  140. TabIndex        =   24
  141. Tag             =   "Select one or more fields to add to the form"
  142. Top             =   300
  143. Width           =   2355
  144. End
  145. End
  146. Begin SSFrame FramFldsOnForm
  147. Alignment       =   2  'Center
  148. Caption         =   "Fields On Form"
  149. ForeColor       =   &H00FF0000&
  150. Height          =   3765
  151. Left            =   3975
  152. TabIndex        =   21
  153. Top             =   90
  154. Width           =   3855
  155. Begin Grid GrdFields
  156. HelpContextID = 26
  157. Cols            =   4
  158. FixedRows       =   0
  159. Height          =   3315
  160. Left            =   120
  161. Rows            =   1
  162. TabIndex        =   22
  163. Tag             =   "Select one or more fields, right click to change attributes"
  164. Top             =   240
  165. Width           =   3555
  166. End
  167. End
  168. End
  169. Begin VideoSoftElastic VSElastic1
  170. HelpContextID = 30
  171. ConvInfo        =   DATAFORM.FRX:0F36
  172. ForeColor       =   &H00FF0000&
  173. Height          =   4455
  174. IntBkg          =   &H00C0C0C0&
  175. Left            =   9945
  176. TabIndex        =   19
  177. TagSplit        =   -1  'True
  178. TagWidth        =   1500
  179. Top             =   495
  180. Width           =   7920
  181. Begin CommonDialog CMDialog2
  182. DefaultExt      =   "frm"
  183. DialogTitle     =   "Save Form As"
  184. Filter          =   "VB Forms|*.frm"
  185. Left            =   660
  186. Top             =   2280
  187. End
  188. Begin SSCommand BtnFindForm
  189. HelpContextID = 35
  190. AutoSize        =   2  'Adjust Button Size To Picture
  191. Font3D          =   2  'Raised w/heavy shading
  192. Height          =   600
  193. Left            =   7020
  194. Picture         =   DATAFORM.FRX:0F41
  195. TabIndex        =   5
  196. Tag             =   "|Press to find the database"
  197. Top             =   1680
  198. Width           =   600
  199. End
  200. Begin TextBox TxtFrmName
  201. HelpContextID = 34
  202. BackColor       =   &H00C0C0C0&
  203. Height          =   375
  204. Left            =   1920
  205. TabIndex        =   4
  206. Tag             =   "Form File Name|Name to save the form as"
  207. Top             =   1920
  208. Width           =   4995
  209. End
  210. Begin SSCommand BtnCancel
  211. AutoSize        =   2  'Adjust Button Size To Picture
  212. Caption         =   "&Cancel"
  213. Font3D          =   2  'Raised w/heavy shading
  214. Height          =   615
  215. Index           =   2
  216. Left            =   3720
  217. Picture         =   DATAFORM.FRX:1243
  218. TabIndex        =   6
  219. Tag             =   "|Cancel building the form"
  220. Top             =   2400
  221. Width           =   915
  222. End
  223. Begin SSCommand BtnFinish
  224. HelpContextID = 33
  225. AutoSize        =   2  'Adjust Button Size To Picture
  226. Caption         =   "&Finish"
  227. Enabled         =   0   'False
  228. Font3D          =   2  'Raised w/heavy shading
  229. Height          =   615
  230. Left            =   4620
  231. Picture         =   DATAFORM.FRX:1545
  232. TabIndex        =   7
  233. Tag             =   "|Generate the form code"
  234. Top             =   2400
  235. Width           =   915
  236. End
  237. Begin SSCommand BtnFindTmplt
  238. HelpContextID = 32
  239. AutoSize        =   2  'Adjust Button Size To Picture
  240. Font3D          =   2  'Raised w/heavy shading
  241. Height          =   600
  242. Left            =   7020
  243. Picture         =   DATAFORM.FRX:1847
  244. TabIndex        =   3
  245. Tag             =   "|Press to find the database"
  246. Top             =   1020
  247. Width           =   600
  248. End
  249. Begin TextBox TxtTmpltName
  250. HelpContextID = 31
  251. BackColor       =   &H00C0C0C0&
  252. Height          =   375
  253. Left            =   1920
  254. TabIndex        =   2
  255. Tag             =   "Form Template|Name of the form template"
  256. Top             =   1260
  257. Width           =   4995
  258. End
  259. Begin SSCommand BtnHelp
  260. Caption         =   "&Help"
  261. Font3D          =   2  'Raised w/heavy shading
  262. Height          =   615
  263. Index           =   2
  264. Left            =   5520
  265. Picture         =   DATAFORM.FRX:1B49
  266. TabIndex        =   8
  267. Top             =   2400
  268. Width           =   915
  269. End
  270. Begin VideoSoftElastic cMsg
  271. Align           =   2  'Bottom
  272. BevelChildren   =   3  'No Graphical or Elastics
  273. BevelInner      =   0  'None
  274. BevelOuter      =   5  'Fillet
  275. BevelOuterWidth =   4
  276. ConvInfo        =   DATAFORM.FRX:1E4B
  277. ForeColor       =   &H00FF0000&
  278. Height          =   375
  279. Index           =   2
  280. IntBkg          =   &H00C0C0C0&
  281. Left            =   0
  282. TabIndex        =   31
  283. Top             =   4080
  284. Width           =   7920
  285. End
  286. Begin TextBox TxtFormCaption
  287. HelpContextID = 6
  288. BackColor       =   &H00C0C0C0&
  289. Height          =   375
  290. Left            =   1935
  291. TabIndex        =   0
  292. Tag             =   "Caption|Caption for the form you are building"
  293. Text            =   "Caption"
  294. Top             =   240
  295. Width           =   3675
  296. End
  297. Begin TextBox TxtFormName
  298. HelpContextID = 5
  299. BackColor       =   &H00C0C0C0&
  300. Height          =   375
  301. Left            =   1920
  302. TabIndex        =   1
  303. Tag             =   "Name|Name for the form you are building"
  304. Text            =   "Name"
  305. Top             =   720
  306. Width           =   3675
  307. End
  308. End
  309. Begin VideoSoftElastic Page
  310. HelpContextID = 17
  311. BevelChildren   =   3  'No Graphical or Elastics
  312. CaptionPos      =   7  'Right Center
  313. ConvInfo        =   DATAFORM.FRX:1E56
  314. ForeColor       =   &H00FF0000&
  315. Height          =   4455
  316. Index           =   0
  317. IntBkg          =   &H00C0C0C0&
  318. Left            =   45
  319. PicturePos      =   0  'Left Top
  320. TabIndex        =   17
  321. TagSplit        =   -1  'True
  322. TagWidth        =   1500
  323. Top             =   495
  324. Width           =   7920
  325. Begin SSCommand BtnHelp
  326. Caption         =   "&Help"
  327. Font3D          =   2  'Raised w/heavy shading
  328. Height          =   615
  329. Index           =   0
  330. Left            =   5100
  331. Picture         =   DATAFORM.FRX:1E61
  332. TabIndex        =   15
  333. Top             =   2100
  334. Width           =   915
  335. End
  336. Begin CommonDialog CMDialog1
  337. DialogTitle     =   "Select Database For Data Control"
  338. Filter          =   "Access Databases|*.mdb"
  339. Left            =   180
  340. Top             =   2220
  341. End
  342. Begin ComboBox LstRecSrce
  343. HelpContextID = 19
  344. BackColor       =   &H00C0C0C0&
  345. Height          =   300
  346. Left            =   1620
  347. Sorted          =   -1  'True
  348. Style           =   2  'Dropdown List
  349. TabIndex        =   13
  350. Tag             =   "Record Source|Select or enter record source for the data control"
  351. Top             =   1680
  352. Width           =   4395
  353. End
  354. Begin SSCommand BtnFindDB
  355. HelpContextID = 20
  356. AutoSize        =   2  'Adjust Button Size To Picture
  357. Font3D          =   2  'Raised w/heavy shading
  358. Height          =   600
  359. Left            =   5400
  360. Picture         =   DATAFORM.FRX:2163
  361. TabIndex        =   12
  362. Tag             =   "|Press to find the database"
  363. Top             =   960
  364. Width           =   600
  365. End
  366. Begin TextBox TxtDBName
  367. HelpContextID = 21
  368. BackColor       =   &H00C0C0C0&
  369. Height          =   375
  370. Left            =   1620
  371. TabIndex        =   11
  372. Tag             =   "Database Name|Name of the database for the data control"
  373. Text            =   "Database Name"
  374. Top             =   1200
  375. Width           =   3675
  376. End
  377. Begin TextBox TxtName
  378. HelpContextID = 22
  379. BackColor       =   &H00C0C0C0&
  380. Height          =   375
  381. Left            =   1620
  382. TabIndex        =   9
  383. Tag             =   "Name|Name for the data control"
  384. Text            =   "DataName"
  385. Top             =   240
  386. Width           =   3675
  387. End
  388. Begin TextBox TxtCaption
  389. HelpContextID = 23
  390. BackColor       =   &H00C0C0C0&
  391. Height          =   375
  392. Left            =   1620
  393. TabIndex        =   10
  394. Tag             =   "Caption|Caption for the data control"
  395. Text            =   "Data Caption"
  396. Top             =   720
  397. Width           =   3675
  398. End
  399. Begin SSCommand BtnCancel
  400. AutoSize        =   2  'Adjust Button Size To Picture
  401. Caption         =   "&Cancel"
  402. Font3D          =   2  'Raised w/heavy shading
  403. Height          =   615
  404. Index           =   0
  405. Left            =   4200
  406. Picture         =   DATAFORM.FRX:2465
  407. TabIndex        =   14
  408. Tag             =   "|Cancel building the form"
  409. Top             =   2100
  410. Width           =   915
  411. End
  412. Begin VideoSoftElastic cMsg
  413. Align           =   2  'Bottom
  414. BevelChildren   =   3  'No Graphical or Elastics
  415. BevelInner      =   0  'None
  416. BevelOuter      =   5  'Fillet
  417. BevelOuterWidth =   4
  418. ConvInfo        =   DATAFORM.FRX:2767
  419. ForeColor       =   &H00FF0000&
  420. Height          =   375
  421. Index           =   0
  422. IntBkg          =   &H00C0C0C0&
  423. Left            =   0
  424. TabIndex        =   18
  425. Top             =   4080
  426. Width           =   7920
  427. End
  428. Begin Image ImgTabPic
  429. Height          =   480
  430. Index           =   2
  431. Left            =   2280
  432. Picture         =   DATAFORM.FRX:2772
  433. Top             =   3180
  434. Visible         =   0   'False
  435. Width           =   480
  436. End
  437. Begin Image ImgTabPic
  438. Height          =   480
  439. Index           =   1
  440. Left            =   1620
  441. Picture         =   DATAFORM.FRX:2A74
  442. Top             =   3180
  443. Visible         =   0   'False
  444. Width           =   480
  445. End
  446. Begin Image ImgTabPic
  447. Height          =   480
  448. Index           =   0
  449. Left            =   840
  450. Picture         =   DATAFORM.FRX:2D76
  451. Top             =   3180
  452. Visible         =   0   'False
  453. Width           =   480
  454. End
  455. End
  456. End
  457. End
  458. Option Explicit
  459. Dim maxwidth(3) As Long
  460.  
  461. Sub BtnAdd_Click ()
  462.     Dim i As Integer, fld As String
  463.  
  464.     ' Add selected feilds to grid
  465.     For i = 0 To LstFields.ListCount - 1
  466.         If LstFields.Selected(i) Then
  467.             fld = LstFields.List(i)
  468.             GrdFields.AddItem fld & Chr$(9) & fld & Chr$(9) & "No" & Chr$(9) & Str$(aiFldSize(i))
  469.             If TextWidth(fld) + 150 > maxwidth(0) Then
  470.                 maxwidth(0) = TextWidth(fld) + 150
  471.                 GrdFields.ColWidth(0) = maxwidth(0)
  472.             End If
  473.             If TextWidth(fld) + 150 > maxwidth(1) Then
  474.                 maxwidth(1) = TextWidth(fld) + 150
  475.                 GrdFields.ColWidth(1) = maxwidth(1)
  476.             End If
  477.         End If
  478.     Next i
  479.     If GrdFields.Rows > 1 Then
  480.         GrdFields.FixedRows = 1
  481.         Mid(RequiredFieldsComplete, 2) = "Y"
  482.         Call SetFinishBtn
  483.     End If
  484.  
  485.  
  486. End Sub
  487.  
  488. Sub BtnAdd_GotFocus ()
  489.     cMsg(1).Caption = BtnAdd.Tag
  490.  
  491. End Sub
  492.  
  493. Sub BtnAdd_LostFocus ()
  494.     cMsg(1).Caption = ""
  495.  
  496. End Sub
  497.  
  498. Sub BtnCancel_Click (Index As Integer)
  499.     EndItNow
  500.  
  501. End Sub
  502.  
  503. Sub BtnCancel_GotFocus (Index As Integer)
  504.     SetStatusBar BtnCancel(Index)
  505.  
  506. End Sub
  507.  
  508. Sub BtnCancel_LostFocus (Index As Integer)
  509.     ClearStatusBar
  510.  
  511. End Sub
  512.  
  513. Sub BtnFindDB_Click ()
  514.     CMDialog1.Flags = OFN_FILEMUSTEXIST
  515.     CMDialog1.Action = 1
  516.     If CMDialog1.Filename <> "" Then
  517.         TxtDBName = CMDialog1.Filename
  518.         GetTableNames
  519.     End If
  520.  
  521. End Sub
  522.  
  523. Sub BtnFindDB_GotFocus ()
  524.     SetStatusBar BtnFindDB
  525.  
  526. End Sub
  527.  
  528. Sub BtnFindDB_LostFocus ()
  529.     ClearStatusBar
  530.  
  531. End Sub
  532.  
  533. Sub BtnFindForm_Click ()
  534.     CMDialog2.DialogTitle = "Save Form As"
  535.     CMDialog2.Filename = TxtName & ".Frm"
  536.     CMDialog2.Flags = OFN_OVERWRITEPROMPT + OFN_PATHMUSTEXIST
  537.     CMDialog2.Action = 2
  538.     If CMDialog2.Filename <> "" Then
  539.         TxtFrmName.Text = CMDialog2.Filename
  540.         Mid(RequiredFieldsComplete, 4) = "Y"
  541.         Call SetFinishBtn
  542.     End If
  543.  
  544.  
  545. End Sub
  546.  
  547. Sub BtnFindForm_GotFocus ()
  548.     SetStatusBar BtnFindForm
  549.  
  550. End Sub
  551.  
  552. Sub BtnFindForm_LostFocus ()
  553.     ClearStatusBar
  554.  
  555. End Sub
  556.  
  557. Sub BtnFindTmplt_Click ()
  558.     CMDialog2.DialogTitle = "Select Form Template"
  559.     CMDialog2.Filename = ""
  560.     CMDialog2.Flags = OFN_FILEMUSTEXIST
  561.     CMDialog2.Action = 1
  562.     If CMDialog2.Filename <> "" Then
  563.         TxtTmpltName = CMDialog2.Filename
  564.         Mid(RequiredFieldsComplete, 3) = "Y"
  565.         Call SetFinishBtn
  566.     End If
  567.     
  568. End Sub
  569.  
  570. Sub BtnFindTmplt_GotFocus ()
  571.     SetStatusBar BtnFindTmplt
  572.  
  573. End Sub
  574.  
  575. Sub BtnFindTmplt_LostFocus ()
  576.     ClearStatusBar
  577.  
  578. End Sub
  579.  
  580. Sub BtnFinish_Click ()
  581.     Dim msg As String, Char As String
  582.     On Error GoTo GenerateErr
  583.  
  584.     mousepointer = HOURGLASS
  585.     ' Verify that file names are correct
  586.     stemplate = TxtTmpltName.Text
  587.     If Right$(UCase$(TxtFrmName.Text), 4) <> ".FRM" Then
  588.         TxtFrmName.Text = TxtFrmName.Text & ".FRM"
  589.     End If
  590.     sForm = TxtFrmName.Text
  591.     If stemplate = "" Then
  592.         Beep
  593.         mousepointer = DEFAULT
  594.         MsgBox "You must specify a form template or use the file drawer button to locate a form template.", 0 + 48 + 0 + 0, "Form Template Error"
  595.         TxtTmpltName.SetFocus
  596.         Exit Sub
  597.     End If
  598.     If Dir$(stemplate) = "" Then
  599.         Beep
  600.         mousepointer = DEFAULT
  601.         MsgBox "The form template you have specified does not exist!  Use the file drawer button to locate a form template.", 0 + 48 + 0 + 0, "Form Template Error"
  602.         TxtTmpltName.SetFocus
  603.         Exit Sub
  604.     End If
  605.     If sForm = "" Then
  606.         Beep
  607.         mousepointer = DEFAULT
  608.         MsgBox "You must specify a form name or use the file drawer button to locate a form.", 0 + 48 + 0 + 0, "Form Save Error"
  609.         TxtFrmName.SetFocus
  610.         Exit Sub
  611.     End If
  612.     If sForm = stemplate Then
  613.         Beep
  614.         mousepointer = DEFAULT
  615.         MsgBox "You cannot use the template as the output form.", 0 + 48 + 0 + 0, "Form Save Error"
  616.         TxtFrmName.SetFocus
  617.         Exit Sub
  618.     End If
  619.     On Error GoTo erropeningtemplate
  620.     Open stemplate For Input Access Read Lock Write As #1
  621.     On Error GoTo erropeningform
  622.     Open sForm For Output Access Write Lock Read Write As #2
  623.     On Error GoTo GenerateErr
  624.     indent = 0
  625.  
  626.     Do While Not EOF(1)
  627.         sFormLine = ""
  628.         
  629.         Do
  630.             Char = Input$(1, #1)
  631.             sFormLine = sFormLine + Char
  632.         Loop While Char <> Chr$(10)
  633.         sFormLine = Left$(sFormLine, Len(sFormLine) - 2)
  634.         Select Case True
  635.         Case InStr(1, sFormLine, "Begin Form", 1) <> 0      ' Beginning of form
  636.             Print #2, "Begin Form " & DataForm.TxtFormName.Text
  637.             indent = 3
  638.         Case InStr(1, sFormLine, "Caption", 1) <> 0         ' Form Caption line
  639.             Print #2, Spc(indent); "Caption = " & Chr$(34) & DataForm.TxtFormCaption.Text & Chr$(34)
  640.         Case InStr(1, sFormLine, "Begin ", 1) <> 0    ' Beginning of control
  641.             Select Case True
  642.             Case InStr(1, sFormLine, " Lbl1", 1) <> 0   ' Beginning of label 1
  643.                 Call SaveLabel1
  644.             Case InStr(1, sFormLine, " Lbl2", 1) <> 0   ' Beginning of label 2
  645.                 Call SaveLabel2
  646.             Case InStr(1, sFormLine, " Fld1", 1) <> 0   ' Beginning of field 1
  647.                 Call SaveField1
  648.             Case InStr(1, sFormLine, " Fld2", 1) <> 0   ' Beginning of field 2
  649.                 Call SaveField2
  650.             Case InStr(1, sFormLine, " Data", 1) <> 0   ' Beginning of data control
  651.                 Call SaveDataCtrl
  652.             Case Else               ' Beginning of other control
  653.                 Call SaveControl
  654.             End Select
  655.         Case InStr(1, sFormLine, "End", 1) <> 0                 ' End of form
  656.             If Len(sFormLine) < InStr(1, sFormLine, "End", 1) + 4 Then
  657.                 Call GotEndOfForm
  658.             Else
  659.                 Print #2, Spc(indent); sFormLine        ' Output any unrecognized lines as is
  660.             End If
  661.         Case Else
  662.             Print #2, Spc(indent); sFormLine        ' Output any unrecognized lines as is
  663.         End Select
  664.  
  665.     Loop
  666.  
  667.     Close #1
  668.     Close #2
  669.     msg = "Form " & sForm & " generated."
  670.     Beep
  671.     mousepointer = DEFAULT
  672.     MsgBox msg, MB_ICONINFORMATION, "Form Wizard Generation"
  673.     
  674.     db.Close        ' Close the database
  675.     MainForm.Show MODELESS
  676.     Unload DataForm
  677.     
  678.     Exit Sub
  679.  
  680. GenerateErr:
  681.     erraction = RB_ErrorHandler("GenForm", "BtnFinish_Click")
  682.     Select Case erraction
  683.     Case 1
  684.         Resume 0      ' Retry option selected
  685.     Case 2
  686.         Resume Next   ' Ignore option selected
  687.     End Select
  688.     On Error Resume Next
  689.     Close #1, #2
  690.     On Error GoTo GenerateErr
  691.     Exit Sub
  692.  
  693. erropeningtemplate:
  694.         Beep
  695.         mousepointer = DEFAULT
  696.         msg = "A " & Error & " error has occurred opening the template file!  Please correct and retry the function"
  697.         MsgBox msg, 0 + 48 + 0 + 0, "Form Template Error"
  698.         TxtTmpltName.SetFocus
  699.         Close #1, #2
  700.         On Error GoTo GenerateErr
  701.         Exit Sub
  702.  
  703. erropeningform:
  704.         Beep
  705.         mousepointer = DEFAULT
  706.         msg = "A " & Error & " error has occurred opening the output form file!  Please correct and retry the function"
  707.         MsgBox msg, 0 + 48 + 0 + 0, "Form Output Error"
  708.         TxtTmpltName.SetFocus
  709.         Exit Sub
  710.  
  711.  
  712. End Sub
  713.  
  714. Sub BtnHelp_Click (Index As Integer)
  715.     SendKeys "{F1}"
  716.  
  717. End Sub
  718.  
  719. Sub BtnHelp_GotFocus (Index As Integer)
  720.     SetStatusBar BtnCancel(Index)
  721.  
  722. End Sub
  723.  
  724. Sub BtnHelp_LostFocus (Index As Integer)
  725.     ClearStatusBar
  726.  
  727. End Sub
  728.  
  729. Sub BtnRemove_Click ()
  730.     On Error GoTo removeerr
  731.     Dim i As Integer, i2 As Integer
  732.     
  733.     ' Remove any selected rows except the last one
  734.     For i = GrdFields.Rows - 2 To 0 Step -1
  735.         GrdFields.Row = i
  736.         GrdFields.Col = 1
  737.         If GrdFields.CellSelected Then
  738.             GrdFields.RemoveItem i
  739.         End If
  740.     Next i
  741.     
  742.     ' Check if last row is deleted and handle special to prevent error
  743.     ' caused by selection defaulting to the entire table when the last
  744.     ' row is removed
  745.     i = GrdFields.Rows - 1
  746.     GrdFields.Row = i
  747.     GrdFields.Col = 1
  748.     If GrdFields.CellSelected Then
  749.         GrdFields.FixedRows = 0
  750.         GrdFields.RemoveItem i
  751.     End If
  752.     GrdFields.Refresh
  753.     If GrdFields.Rows > 1 Then GrdFields.FixedRows = 1
  754.  
  755.     Exit Sub
  756.  
  757. removeerr:
  758.     erraction = RB_ErrorHandler("FieldFrm", "BtnRemove_Click")
  759.     Select Case erraction
  760.     Case 1
  761.         Resume 0      ' Retry option selected
  762.     Case 2
  763.         Resume Next   ' Ignore option selected
  764.     End Select
  765.  
  766.  
  767. End Sub
  768.  
  769. Sub BtnRemove_GotFocus ()
  770.     cMsg(1).Caption = BtnRemove.Tag
  771.  
  772. End Sub
  773.  
  774. Sub BtnRemove_LostFocus ()
  775.     cMsg(1).Caption = ""
  776.  
  777. End Sub
  778.  
  779. Sub ClearStatusBar ()
  780.     cMsg(VsIndexTab1.CurrTab).Caption = ""
  781.  
  782. End Sub
  783.  
  784. Sub FldGotFocus (PControl As Control)
  785.     PControl.BackColor = BLUE
  786.     PControl.ForeColor = WHITE
  787.     If TypeOf PControl Is TextBox Then
  788.         PControl.SelStart = 0
  789.         PControl.SelLength = 1000
  790.     End If
  791.     If InStr(PControl.Tag, "|") = 0 Then
  792.         cMsg(VsIndexTab1.CurrTab).Caption = PControl.Tag
  793.     Else
  794.         cMsg(VsIndexTab1.CurrTab).Caption = Mid$(PControl.Tag, InStr(PControl.Tag, "|") + 1)
  795.     End If
  796.  
  797. End Sub
  798.  
  799. Sub FldLostFocus (PControl As Control)
  800.     PControl.BackColor = RB_GRAY
  801.     PControl.ForeColor = BLACK
  802.     cMsg(VsIndexTab1.CurrTab).Caption = ""
  803.  
  804. End Sub
  805.  
  806. Sub Form_Load ()
  807.     On Error GoTo loaderr
  808.  
  809.     ' Set up grid headings
  810.     GrdFields.Row = 0
  811.     GrdFields.Col = 0
  812.     GrdFields.Text = "Field"
  813.     GrdFields.ColWidth(0) = TextWidth(" Field ")
  814.     maxwidth(0) = GrdFields.ColWidth(0)
  815.     GrdFields.Col = 1
  816.     GrdFields.Text = "Label"
  817.     GrdFields.ColWidth(1) = TextWidth(" Label ")
  818.     maxwidth(1) = GrdFields.ColWidth(1)
  819.     GrdFields.Col = 2
  820.     GrdFields.Text = "Same" & Chr$(13) & "Line"
  821.     GrdFields.ColWidth(2) = TextWidth(" Same ")
  822.     maxwidth(2) = GrdFields.ColWidth(2)
  823.     GrdFields.Col = 3
  824.     GrdFields.Text = "Size"
  825.     GrdFields.ColWidth(3) = TextWidth(" Size ")
  826.     GrdFields.RowHeight(0) = 2 * TextHeight("Same")
  827.     VsIndexTab1.TabEnabled(1) = False
  828.     VsIndexTab1.TabPicture(0) = ImgTabPic(0)
  829.     VsIndexTab1.TabPicture(1) = ImgTabPic(1)
  830.     VsIndexTab1.TabPicture(2) = ImgTabPic(2)
  831.  
  832.  
  833.     Exit Sub
  834.  
  835. loaderr:
  836.     erraction = RB_ErrorHandler("FieldFrm", "Form_Load")
  837.     Select Case erraction
  838.     Case 1
  839.         Resume 0      ' Retry option selected
  840.     Case 2
  841.         Resume Next   ' Ignore option selected
  842.     End Select
  843.  
  844.  
  845. End Sub
  846.  
  847. Sub Form_Resize ()
  848.     If DataForm.WindowState <> 1 Then       ' If not minimized
  849.         If VsIndexTab1.CurrTab = 1 Then     ' If field tab is current
  850.             FramFldsOnForm.Width = DataForm.Width - FramFldsOnForm.Left - 250
  851.             GrdFields.Width = FramFldsOnForm.Width - GrdFields.Left - 150
  852.         End If
  853.     End If
  854.  
  855. End Sub
  856.  
  857. Sub GetTableNames ()
  858.     ' Get names of tables in selected database
  859.     Dim sstables As snapshot, msg As String
  860.  
  861.     On Error GoTo GetTablesErr
  862.     mousepointer = HOURGLASS
  863.     If TxtDBName.Text = "" Then Exit Sub
  864.     On Error GoTo OpenDBErr
  865.     If Dir$(TxtDBName.Text) = "" Then
  866.         Beep
  867.         MsgBox "The database name you have specified does not exist!  Use the file drawer button to locate a database.", 0 + 48 + 0 + 0, "Database Selection Error"
  868.         TxtDBName.SetFocus
  869.         mousepointer = DEFAULT
  870.         Exit Sub
  871.     End If
  872.     LstRecSrce.Clear
  873.     Set db = OpenDatabase(TxtDBName.Text)
  874.     On Error GoTo GetTablesErr
  875.     Set sstables = db.ListTables()
  876.     Do While Not sstables.EOF
  877.         If sstables!Attributes And DB_SYSTEMOBJECT Then
  878.         Else
  879.             LstRecSrce.AddItem sstables!Name
  880.         End If
  881.         sstables.MoveNext
  882.     Loop
  883.     sstables.Close
  884.     LstRecSrce.ListIndex = 0
  885.     Mid(RequiredFieldsComplete, 1, 1) = "Y"
  886.     Call SetFinishBtn
  887.     mousepointer = DEFAULT
  888.  
  889.     Exit Sub
  890.  
  891. OpenDBErr:
  892.     Beep
  893.     mousepointer = DEFAULT
  894.     msg = "A " & Error & " error has occurred opening the database!  Please correct and retry the function"
  895.     MsgBox msg, 0 + 48 + 0 + 0, "Database Specification Error"
  896.     TxtDBName.SetFocus
  897.     On Error GoTo GetTablesErr
  898.     mousepointer = DEFAULT
  899.     Exit Sub
  900.  
  901.  
  902. GetTablesErr:
  903.     mousepointer = DEFAULT
  904.     erraction = RB_ErrorHandler("DataSpec", "GetTableNames")
  905.     Select Case erraction
  906.     Case 1
  907.         Resume 0      ' Retry option selected
  908.     Case 2
  909.         Resume Next   ' Ignore option selected
  910.     End Select
  911.     
  912. End Sub
  913.  
  914. Sub GrdFields_GotFocus ()
  915.     cMsg(1).Caption = GrdFields.Tag
  916.  
  917. End Sub
  918.  
  919. Sub GrdFields_LostFocus ()
  920.     cMsg(1).Caption = ""
  921.  
  922. End Sub
  923.  
  924. Sub GrdFields_MouseUp (Button As Integer, Shift As Integer, X As Single, Y As Single)
  925.     Dim i As Integer, istart As Integer, iend As Integer
  926.     If Button = RIGHT_BUTTON Then
  927.         istart = GrdFields.SelStartRow
  928.         If istart = 0 Then istart = 1
  929.         iend = GrdFields.SelEndRow
  930.         For i = istart To iend
  931.             GrdFields.Row = i
  932.             GrdFields.Col = 0
  933.             ChngFld.LblField.Caption = GrdFields.Text
  934.             GrdFields.Col = 1
  935.             ChngFld.TxtLabel = GrdFields.Text
  936.             GrdFields.Col = 2
  937.             If GrdFields.Text = "Yes" Then
  938.                 ChngFld.ChkSameLine.Value = True
  939.             Else
  940.                 ChngFld.ChkSameLine.Value = False
  941.             End If
  942.             ChngFld.LblRow.Caption = Str$(i)
  943.             ChngFld.Show MODAL
  944.         Next i
  945.     End If
  946.  
  947.  
  948. End Sub
  949.  
  950. Sub LstFields_GotFocus ()
  951.     cMsg(1).Caption = LstFields.Tag
  952.  
  953. End Sub
  954.  
  955. Sub LstFields_LostFocus ()
  956.     cMsg(1).Caption = ""
  957.  
  958. End Sub
  959.  
  960. Sub LstRecSrce_Click ()
  961.     Dim ds As dynaset, ssfields As snapshot
  962.     Dim iNumFlds As Integer
  963.     On Error GoTo LoadListErr
  964.  
  965.     ' Load list of fields in record source
  966.     mousepointer = HOURGLASS
  967.     Set ds = db.CreateDynaset(LstRecSrce.Text)
  968.     Set ssfields = ds.ListFields()
  969.     ds.Close
  970.     LstFields.Clear
  971.     ReDim aiFldSize(1)
  972.     iNumFlds = -1
  973.     Do While Not ssfields.EOF
  974.         LstFields.AddItem ssfields!Name
  975.         iNumFlds = iNumFlds + 1
  976.         ReDim Preserve aiFldSize(iNumFlds)
  977.         aiFldSize(iNumFlds) = ssfields!Size
  978.         ssfields.MoveNext
  979.     Loop
  980.     ssfields.Close
  981.     NewRecordSource = False
  982.     ' Clear the grid of fields
  983.     GrdFields.Rows = 1
  984.     VsIndexTab1.TabEnabled(1) = True    ' Enable the Fields tab
  985.     mousepointer = DEFAULT
  986.     
  987.     Exit Sub
  988.  
  989. LoadListErr:
  990.     erraction = RB_ErrorHandler("FieldFrm", "Form_Activate")
  991.     Select Case erraction
  992.     Case 1
  993.         Resume 0      ' Retry option selected
  994.     Case 2
  995.         Resume Next   ' Ignore option selected
  996.     End Select
  997.     
  998.  
  999. End Sub
  1000.  
  1001. Sub LstRecSrce_GotFocus ()
  1002.     FldGotFocus LstRecSrce
  1003.  
  1004. End Sub
  1005.  
  1006. Sub LstRecSrce_LostFocus ()
  1007.     FldLostFocus LstRecSrce
  1008.  
  1009. End Sub
  1010.  
  1011. Sub SetFinishBtn ()
  1012.     ' Check if Finish Button should be enabled
  1013.     If RequiredFieldsComplete = "YYYY" Then
  1014.         BtnFinish.Enabled = True
  1015.     Else
  1016.         BtnFinish.Enabled = False
  1017.     End If
  1018. End Sub
  1019.  
  1020. Sub SetStatusBar (PControl As Control)
  1021.     If InStr(PControl.Tag, "|") = 0 Then
  1022.         cMsg(VsIndexTab1.CurrTab).Caption = PControl.Tag
  1023.     Else
  1024.         cMsg(VsIndexTab1.CurrTab).Caption = Mid$(PControl.Tag, InStr(PControl.Tag, "|") + 1)
  1025.     End If
  1026.  
  1027. End Sub
  1028.  
  1029. Sub TxtCaption_GotFocus ()
  1030.     FldGotFocus TxtCaption
  1031.  
  1032. End Sub
  1033.  
  1034. Sub TxtCaption_LostFocus ()
  1035.     FldLostFocus TxtCaption
  1036.  
  1037. End Sub
  1038.  
  1039. Sub TxtDBName_GotFocus ()
  1040.     FldGotFocus TxtDBName
  1041.  
  1042. End Sub
  1043.  
  1044. Sub TxtDBName_LostFocus ()
  1045.     FldLostFocus TxtDBName
  1046.     If TxtDBName.DataChanged Then
  1047.         GetTableNames
  1048.     End If
  1049.  
  1050. End Sub
  1051.  
  1052. Sub TxtFormCaption_GotFocus ()
  1053.     FldGotFocus TxtFormCaption
  1054.  
  1055. End Sub
  1056.  
  1057. Sub TxtFormCaption_LostFocus ()
  1058.     FldLostFocus TxtFormCaption
  1059.  
  1060. End Sub
  1061.  
  1062. Sub TxtFormName_GotFocus ()
  1063.     FldGotFocus TxtFormName
  1064.  
  1065. End Sub
  1066.  
  1067. Sub TxtFormName_LostFocus ()
  1068.     FldLostFocus TxtFormName
  1069.  
  1070. End Sub
  1071.  
  1072. Sub TxtFrmName_GotFocus ()
  1073.     FldGotFocus TxtFrmName
  1074.  
  1075. End Sub
  1076.  
  1077. Sub TxtFrmName_LostFocus ()
  1078.     FldLostFocus TxtFrmName
  1079.     If TxtFrmName.Text <> "" Then
  1080.         Mid(RequiredFieldsComplete, 4) = "Y"
  1081.         Call SetFinishBtn
  1082.     End If
  1083.  
  1084. End Sub
  1085.  
  1086. Sub TxtName_GotFocus ()
  1087.     FldGotFocus TxtName
  1088.  
  1089. End Sub
  1090.  
  1091. Sub TxtName_LostFocus ()
  1092.     FldLostFocus TxtName
  1093.  
  1094. End Sub
  1095.  
  1096. Sub TxtTmpltName_GotFocus ()
  1097.     FldGotFocus TxtTmpltName
  1098.  
  1099. End Sub
  1100.  
  1101. Sub TxtTmpltName_LostFocus ()
  1102.     FldLostFocus TxtTmpltName
  1103.     If TxtTmpltName.Text <> "" Then
  1104.         Mid(RequiredFieldsComplete, 3) = "Y"
  1105.         Call SetFinishBtn
  1106.     End If
  1107.  
  1108. End Sub
  1109.  
  1110.